package com.gmcloud.upms.api.system.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gmcloud.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.validation.constraints.NotBlank;
import java.io.Serial;

/**
 * @author zl.sir
 * @version 1.0
 * @since 2022/8/18 12:15
 */
public class SysLog extends BaseEntity {

    @Serial
    private static final long serialVersionUID = 723414919556594840L;

    /**
     * 编号
     */
    @TableId(value = "log_id", type = IdType.ASSIGN_ID)
    @ExcelProperty("日志编号")
    @Schema(description = "日志编号")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 日志类型
     */
    @NotBlank(message = "日志类型不能为空")
    @ExcelProperty("日志类型（0-正常 9-错误）")
    @Schema(description = "日志类型")
    private String type;

    /**
     * 日志标题
     */
    @NotBlank(message = "日志标题不能为空")
    @ExcelProperty("日志标题")
    @Schema(description = "日志标题")
    private String title;

    /**
     * 操作IP地址
     */
    @ExcelProperty("IP")
    @Schema(description = "操作ip地址")
    private String remoteAddr;

    /**
     * 用户浏览器
     */
    @ExcelProperty("浏览器类型")
    @Schema(description = "用户代理")
    private String userAgent;

    /**
     * 请求URI
     */
    @ExcelProperty("请求URI")
    @Schema(description = "请求uri")
    private String requestUri;

    /**
     * 操作方式
     */
    @ExcelProperty("操作方式")
    @Schema(description = "操作方式")
    private String method;

    /**
     * 操作提交的数据
     */
    @ExcelProperty("请求参数")
    @Schema(description = "数据")
    private String params;

    @ExcelProperty("请求体")
    @Schema(description = "请求体")
    private String body;

    /**
     * 执行时间
     */
    @ExcelProperty("方法执行时间")
    @Schema(description = "方法执行时间")
    private Long time;

    /**
     * 异常信息
     */
    @ExcelProperty("异常信息")
    @Schema(description = "异常信息")
    private String exception;

    /**
     * 服务ID
     */
    @ExcelProperty("应用标识")
    @Schema(description = "应用标识")
    private String serviceId;

    /**
     * 删除标识（0-正常,1-删除）
     */
    @TableLogic
    @ExcelIgnore
    private String delFlag;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getRemoteAddr() {
        return remoteAddr;
    }

    public void setRemoteAddr(String remoteAddr) {
        this.remoteAddr = remoteAddr;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getRequestUri() {
        return requestUri;
    }

    public void setRequestUri(String requestUri) {
        this.requestUri = requestUri;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getParams() {
        return params;
    }

    public void setParams(String params) {
        this.params = params;
    }

    public Long getTime() {
        return time;
    }

    public void setTime(Long time) {
        this.time = time;
    }

    public String getException() {
        return exception;
    }

    public void setException(String exception) {
        this.exception = exception;
    }

    public String getServiceId() {
        return serviceId;
    }

    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }
}
